(function (i, j) {
    var c = i.bShareUtil, o = i.bShareControl, q = j.body;
    c.createShareBox = function (n) {
        var b = i[n], f = b.config;
        b.createBox = function (e) {
            e = e || b.boxConfig;
            e.hasMore = e.hasMore && f.mdiv >= 0;
            var a = e.id || "bsBox";
            if (!c.getElemById(a)) {
                c.loadStyle(".bsBox{display:none;z-index:100000001;font-size:12px;background:url(" + b.imageBasePath + "/background-opaque-dark.gif) !important;padding:6px !important;-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;}.bsClose{_overflow:hidden;cursor:pointer;position:absolute;z-index:10000000;color:#666;font-weight:bold;font-family:Helvetica,Arial;font-size:14px;line-height:20px;}.bsTop{color:" +
                    f.poptxtc + ";background:" + f.popbgc + ";height:24px;line-height:24px;border-bottom:1px solid #e8e8e8;}.bsTop span{float:left;}.bsFrameDiv,#bsMorePanel{border:none;background:#fff;}.bsReturn{float:right;*margin-right:20px;margin-right:36px;text-align:right;cursor:pointer;line-height:24px;color:#666;opacity:0.5;}#bsReturn:hover{text-decoration:underline;opacity:1;}");
                var d;
                d = '<div class="bsClose">X</div>';
                e.hasTop && (d += '<div class="bsTop">' + (e.hasMore ? '<div class="bsReturn">\u9009\u62e9\u5176\u4ed6\u5e73\u53f0 &gt;&gt;</div>' : "") + '<span style="margin-left:15px;">' +
                    (b.params.promote ? b.iL8n.shareTextPromote : b.iL8n.shareText) + '</span><span class="bsPlatName"></span></div>');
                d += '<div class="bsFrameDiv">' + (e.hasFrame ? '<iframe class="bShareFrame" name="bsFrame' + ~~(Math.random() * 1E3) + '" frameborder="0" scrolling="no" allowtransparency="true"></iframe>' : "<div></div>") + "</div>" + (e.hasMore ? '<div id="bsMorePanel" style="display: none;"></div>' : "");
                a = c.createElement("div", a, "bsBox", "", d);
                q.appendChild(a);
                c.getElem(a, "div", "bsClose")[0].onclick = function () {
                    b.disappear()
                };
                if (e.hasMore) c.getElem(a, "div", "bsReturn")[0].onclick = function () {
                    b.moreDiv()
                }
            }
        };
        b.resetBox = function (c, a) {
            b.boxConfig[c] = a
        };
        b.getFrame = function (e) {
            e = e || b.boxConfig;
            e = c.getElemById(e.id || "bsBox");
            return c.getElem(e, "div", "bsFrameDiv")[0].firstChild
        };
        b.disappear = function () {
            var b = c.getElem(j, "div", "bsBox"), a, d;
            for (a = 0, d = b.length; a < d; ++a) b[a].style.display = "none"
        };
        b.display = function (e, a) {
            b.disappear();
            a = a || b.boxConfig;
            a.hasMore = a.hasMore && f.mdiv >= 0;
            c.getElem(j, "div", "bsBox");
            var d = c.getElemById(a.id ||
                "bsBox"), g = c.getElem(d, "div", "bsClose")[0], k = c.getElem(d, "span", "bsPlatName")[0],
                h = c.getElem(d, "div", "bsFrameDiv")[0].firstChild, i = c.getElemById("bsMorePanel"), r = e ? i : h,
                l = a.position = a.position || 0, m = l ? c.getOffset(c.getElem(j, "a", a.anchor)[b.curb]) : null;
            d.style.left = l ? m.x + "px" : "50%";
            d.style.top = l ? m.y + m.h + 2 + "px" : "50%";
            d.style.marginLeft = l ? 0 : -a.boxWidth / 2 + "px";
            d.style.marginTop = l ? 0 : -a.boxHeight / 2 + "px";
            d.style.position = !l && !c.isQk() ? "fixed" : "absolute";
            g.style.top = a.closeTop + "px";
            g.style.right = a.closeRight +
                "px";
            r.style.height = a.boxHeight - (a.hasTop ? 25 : 0) + "px";
            r.style.width = a.boxWidth + "px";
            r.style.display = "block";
            d.style.height = a.boxHeight + "px";
            d.style.width = a.boxWidth + "px";
            d.style.display = "block";
            if (a.hasTop && (c.getElem(d, "div", "bsTop")[0].style.width = a.boxWidth + "px", b.params.target)) k.innerHTML = "&nbsp;-&nbsp;" + b.pnMap[b.params.target][0];
            if (a.hasMore) e ? (h.style.display = "none", k.style.display = "none") : (i.style.display = "none", k.style.display = "block"), c.getElem(d, "div", "bsReturn")[0].style.display = e ? "none" :
                ""
        }
    };
    c.loadEngine = function (n) {
        var b = i[n], f = b.config, e = b.params;
        b.prepare = function (a) {
            var d = {};
            typeof a == "object" ? d = a : (b.curb = c.isUndefined(a) ? b.curb : a, b.curb >= 0 && (d = b.entries[b.curb] || {}));
            e.url = d.url || e.url || i.location.href;
            e.title = d.title || e.title;
            if (!e.title) e.title = /([^-_]*).*/.exec(j.title)[1];
            e.summary = d.summary ? c.shortenText(d.summary, 110) : e.summary || c.getContent();
            e.lang = e.request_locale = f.lang;
            e.pics = d.pics || c.getPics();
            e.pic = d.pic || e.pic;
            for (var g in d) /url|title|summary|content/.test(g) ||
            (e[g] = d[g])
        };
        b.share = function (a, d, g) {
            b.prepare(g);
            b.load(d) && b.afterLoad && b.afterLoad(d);
            c.stopProp(a)
        };
        b.stats = function (a, d, g) {
            b.prepare(g);
            b.shareStats(d);
            c.stopProp(a)
        };
        b.shareStats = function (a) {
            var d = b.bhost + "/bshare_share_statistics?";
            d += "site=" + a;
            d += "&url=" + c.encode(e.url);
            d += "&title=" + c.encode(e.title);
            d += "&publisherUuid=" + e.publisherUuid;
            d += "&type=" + e.type;
            c.loadScript(d)
        };
        b.view = function (a) {
            a = a || i.location.href;
            if (o.viewed) {
                var d = 0, g = function () {
                    b.viewInfo ? b.viewcb() : d >= 6 || (++d, setTimeout(g,
                        500))
                };
                b.viewInfo || g()
            } else {
                o.viewed = !0;
                var k = b.bhost + "/bshare_view?Callback=" + n + ".viewcb&";
                k += "url=" + c.encode(a);
                k += "&h=" + c.encode(i.location.hash);
                k += "&uuid=" + e.publisherUuid;
                f.showShareCount && (k += "&sc=1");
                k += b.bpsCount ? "&l=" + b.bpsCount : "&l=17";
                this.isLite && (k += "&lite=1");
                if (j.referrer) {
                    var a = j.referrer, h, p;
                    h = c.parseOptions(a, !0);
                    if (a.indexOf(".baidu.") > -1) p = h.wd || h.word; else if (/\.(google|bing|so)\./.test(a)) p = h.q; else if (a.indexOf(".yahoo.") > -1) p = h.p || h.keyword; else if (a.indexOf(".sogou.") > -1) p =
                        h.query; else if (a.indexOf(".youdao.") > -1) p = h.q || h.keyword; else if (a.indexOf(".soso.") > -1) p = h.w;
                    k += "&ref=" + c.encode(a);
                    k = c.addUrlCValue(k, "q", p)
                }
                k = c.addUrlCValue(k, "ot", j.title);
                k = c.addUrlCValue(k, "kws", c.keywords());
                c.loadScript(k)
            }
        };
        b.click = function () {
            if (!o.clicked && (o.clicked = !0, b.preb !== b.curb)) {
                b.preb = b.curb;
                var a = b.bhost + "/bshare_click?";
                a += "url=" + c.encode(b.params.url);
                a += "&title=" + c.encode(b.params.title);
                a += "&uuid=" + e.publisherUuid;
                c.loadScript(a)
            }
        };
        b.showPromo = function (a) {
            a.style.position =
                "relative";
            var d = c.isQk() || (j.documentMode ? +j.documentMode == 7 : c.isIe7);
            a.style.display = d ? "inline" : "inline-block";
            if (d) a.style.zoom = "1";
            c.getElem(a, "div", "bsPromo", function (d, e) {
                d.style.display = "block";
                if (!b.isLite || f.style != -1) d.innerHTML = b.iL8n ? b.iL8n.promote : "\u5206\u4eab\u6709\u793c", a.style.overflow = "visible"; else var h = setInterval(function () {
                    if (b.anchorsBinded) {
                        clearInterval(h);
                        var i = c.getElem(a, "a", "bshare-bsharesync")[0], f = c.getElem(a, "a", "bshare-more"),
                            l = f[f.length - 1], m, n, o;
                        if (i || l) {
                            m = i || l;
                            f = m.offsetHeight ||
                                0;
                            if (f < 20 && (!i || i.offsetLeft < l.offsetLeft)) m = l;
                            l = a.style.paddingTop || 0;
                            n = m.offsetLeft || 0;
                            o = !!m.innerHTML && m.innerHTML.length != 0;
                            var s = "31px", t = "29px", u = n + (f < 36 ? 32 : 50) - 31 + "px",
                                v = l + (f < 36 ? 0 : -1) + "px";
                            f < 20 ? (m.style.marginRight = "21px", d.style.cursor = "default", s = "21px", t = "16px", u = (m.offsetLeft || 0) + (o ? m.offsetWidth || 0 : 18) + "px", v = l + 1 + "px") : f < 28 ? (d.style.backgroundPosition = "0 -16px", t = s = "22px", u = n + 24 - 22 + "px", v = l + "px") : d.style.backgroundPosition = "0 -38px";
                            d.style.width = s;
                            d.style.height = t;
                            d.style.left = u;
                            d.style.top =
                                v;
                            if (!(f < 20)) if (i) d.onclick = function (a) {
                                b.share(a, "bsharesync", e)
                            }; else var q = setInterval(function () {
                                if (b.hover) clearInterval(q), d.onmouseover = function () {
                                    b.hover(m)
                                }, d.onmouseout = function () {
                                    b.timerId = setTimeout(function () {
                                        j.getElementById("bsPanel").style.display = "none"
                                    }, 50)
                                }, d.onclick = function (a) {
                                    b.more(a, e)
                                }
                            }, 100)
                        }
                    }
                }, 100)
            })
        };
        b.promote = function () {
            e.promote = !0;
            b.resetBox && b.resetBox("boxHeight", 588);
            if (f.namespace == "bShare") switch (b.resetBox && b.resetBox("boxHeight", 588), f.style) {
                case 3:
                    if (f.text ==
                        b.iL8n.shareText) f.text = b.iL8n.shareTextPromote;
                case 4:
                case 5:
                    return
            }
            i.bShareLike ? c.getElem(j, "a", "bsLikeDiv", function (a) {
                b.showPromo(a, c.getElem(a, "div", "bsPromo")[0])
            }) : (c.getElem(j, "a", "bshareDiv", function (a) {
                b.showPromo(a, c.getElem(a, "div", "bsPromo")[0])
            }), c.getElem(j, "div", "bshare-custom", function (a) {
                b.showPromo(a, c.getElem(a, "div", "bsPromo")[0])
            }))
        };
        b.viewcb = function (a) {
            o.bShareLoad = !0;
            a = b.viewInfo = b.viewInfo || a;
            if (typeof a.c == "number" && b.entries.length == 0) a.c = a.c > -1 ? a.c : 0, b.showCount(a.c);
            if (a.n) b.user = a.n;
            if (a.p && a.p.length > 0) f.bps = c.getPNames(a.p);
            f.lang != "en" && (f.promote || a.pt) && typeof b.promote == "function" && b.promote();
            (a.n || a.p) && typeof b.ready == "function" && b.ready();
            a.lk && b.entries.length <= 1 && typeof b.showStatus == "function" && b.showStatus(a.lk);
            a.cl && typeof b.collect == "function" && b.collect();
            b.cmatch(a.v, a.m)
        };
        b.cmatch = function (a, d) {
            if (a && d) {
                var g = c.createElement("iframe", "", "", "display:none;");
                g.src = b.shost + "/cm.html?cid=" + a + "&m=" + d;
                q.appendChild(g)
            }
        };
        b.collect = function () {
            var a =
                b.bhost + "/bshare_log_params?uuid=" + e.publisherUuid, d;
            for (d in b.customization) a += "&" + d + "=" + b.customization[d];
            c.loadScript(a)
        };
        b.count = function (a) {
            if (f.showShareCount) {
                var d = b.bhost + "/bshare_share_count?Callback=" + n + ".showCount";
                d += "&url=" + c.encode(a);
                c.loadScript(d)
            }
        };
        b.shareCount = function (a, d) {
            /0|2|10/.test(f.style) ? a = c.longRound(a) : /11/.test(f.style) || (a = c.shortRound(a));
            var b = {cssFloat: "none"};
            if (n != "bShareLike") switch (f.style) {
                case 1:
                    b.left = "36px";
                    b.color = "#fff";
                    b.fontsize = "12px";
                    break;
                case 10:
                    b.left =
                        "27px";
                case 0:
                case 2:
                    b.fontsize = "11px";
                    break;
                case 11:
                    b.top = "25px", b.fontsize = "17px"
            }
            if (d) {
                var e = d.style, h;
                for (h in b) if (h != "color" || !e.color) e[h] = b[h];
                d.innerHTML = c.addCommas(a)
            } else return c.addCommas(a)
        };
        b.showCount = function (a) {
            b.counters = a;
            var d = c.getElem(j, "span", "shareCount");
            if (!d || d.length == 0) d = c.getElem(j, "span", "BSHARE_COUNT");
            var g, e;
            if (typeof a == "number") {
                for (g = 0, e = d.length; g < e; g++) b.shareCount(a, d[g]);
                c.getElem(j, "span", "BSHARE_COUNT", function (d) {
                    d.innerHTML = "" + b.shareCount(a, null)
                })
            } else if (a.length >
                0) {
                e = a.length;
                for (g = 0; g < e; g++) b.shareCount(a[g], d[g]);
                if (!(b.entries.length < e)) for (g = e - 1; g < d.length; g++) b.shareCount(a[e - 1], d[g])
            }
        };
        b.updateCounter = function (a) {
            typeof b.counters == "number" ? b.counters += a ? -1 : 1 : b.counters[b.curb] += a ? -1 : 1;
            b.showCount(b.counters)
        };
        c.roundNumber = function (a, b) {
            try {
                return Math.round(a * Math.pow(10, b)) / Math.pow(10, b)
            } catch (c) {
                return a
            }
        };
        c.keywords = function () {
            var a = "", b = document.getElementsByTagName("meta");
            if (b) for (var c = 0, e = b.length; c < e; c++) /^keywords$/i.test(b[c].name) && (a +=
                b[c].content);
            return a
        };
        c.addUrlCValue = function (a, b, e) {
            if (e) {
                try {
                    decodeURIComponent(e)
                } catch (f) {
                }
                a += "&" + b + "=" + e;
                if (a.indexOf("cs") < 0) b = document.charset, a += b ? "&cs=" + c.encode(b) : ""
            }
            return a
        };
        c.longRound = function (a) {
            if (a > 999999) return c.roundNumber(a / 1E6, 2) + "M"; else if (a > 99999) return c.roundNumber(a / 1E3, 1) + "K";
            return a
        };
        c.shortRound = function (a) {
            if (a > 999999) return c.roundNumber(a / 1E6, 1) + "M"; else if (a > 99999) return c.roundNumber(a / 1E3, 0) + "K"; else if (a > 9999) return c.roundNumber(a / 1E3, 1) + "K"; else if (a > 999) return c.roundNumber(a /
                1E3, 2) + "K";
            return a
        };
        c.addCommas = function (a) {
            try {
                a += "";
                for (var b = a.split("."), c = b[0], e = b.length > 1 ? "." + b[1] : "", b = /(\d+)(\d{3})/; b.test(c);) c = c.replace(b, "$1,$2");
                return c + e
            } catch (f) {
                return a
            }
        };
        c.shortenText = function (a, b) {
            a = a || "";
            return a.length > b ? a.slice(0, b) + "..." : a
        };
        c.getCurrentSelection = function () {
            var a = "";
            if (i.getSelection) a = i.getSelection().toString(); else if (j.getSelection) a = j.getSelection; else if (j.selection) try {
                a = j.selection.createRange().text
            } catch (b) {
            }
            return a
        };
        c.grabTextContent = function () {
            for (var a =
                "", b = j.getElementsByTagName("p"), e = 0, f = b.length; e < f; e++) {
                var h = b[e];
                if (h.id == "BSHARE_TEXT" || h.className.indexOf("BSHARE_TEXT") != -1) a += c.getText(h)
            }
            a == "" && c.getElem(j, "meta", null, function (b) {
                var c = b.getAttribute("name");
                c && /^description$/i.test(c) && (a = b.getAttribute("content"))
            });
            return a
        };
        c.getContent = function () {
            var a = null, b = c.getCurrentSelection();
            return b ? c.shortenText(b, 110) : (a === null && (a = c.grabTextContent()), c.shortenText(a, 110))
        };
        c.getPics = function () {
            for (var a = "", b = c.getElem(j, "img"), e = 0, f = b.length; e <
            f; e++) {
                var h = b[e];
                if (!(h.offsetHeight <= 119 || h.offsetWidth <= 119)) {
                    if (a.length + h.src.length >= 1500) break;
                    a != "" && (a += "|");
                    a += h.src
                }
            }
            return a
        };
        c.removeUrlHash = function (a) {
            var b = a.indexOf("#");
            b > 0 && (a = a.slice(0, b));
            return a
        };
        c.showClipboardSuccess = function () {
            alert(b.iL8n.copySuccess)
        };
        c.showClipboardUnsupportBrowsertxt = function (a) {
            prompt(b.iL8n.copyTip, a)
        };
        c.getPNames = function (a) {
            var c = [], e;
            for (e in a) c.push(b.plats[a[e]]);
            return c
        };
        c.copy2Clipboard = function () {
            try {
                var a = c.removeUrlHash(e.url), b = e.title +
                    " " + a, f = i.clipboardData;
                f ? (f.clearData(), f.setData("Text", b), c.showClipboardSuccess()) : c.showClipboardUnsupportBrowsertxt(b)
            } catch (j) {
            }
        };
        c.add2Printer = function () {
            i.print()
        };
        c.add2Bookmark = function () {
            if (i.sidebar) i.sidebar.addPanel(e.title, e.url, ""); else if (i.chrome) alert(b.iL8n.bookmarkTip); else if (i.external) try {
                i.external.AddFavorite(e.url, e.title)
            } catch (a) {
            } else if (i.opera && i.print) return !0; else alert(b.iL8n.notSupport)
        }
    }
})(window, document);
